<template>
  <div>
    <div class="acea-row row-middle row-between">
      <div class="acea-row row-middle">
        <el-input v-model="qiduanVal" style="width: 200px;margin-right: 10px" placeholder="起端类型"></el-input>
        <el-input v-model="zhongduanVal" style="width: 200px;margin-right: 10px" placeholder="终端类型"></el-input>
        <el-button type="primary" @click="openTaskPopup">任务列表</el-button>
        <el-button type="primary">开始测试</el-button>
        <el-button type="primary">指定测试</el-button>
        <el-button type="primary">执行单条数据</el-button>
        <el-button type="primary" plain>停止</el-button>
        <el-button type="primary" plain>计量点输入</el-button>
      </div>
      <div class="acea-row row-middle">
        <el-button type="primary">质检人</el-button>
        <el-button type="primary">互检人</el-button>
        <el-button type="primary">上传EPE</el-button>
      </div>
    </div>
    <div class="mt20">
      <el-table
          :data="tableData"
          border
          style="width: 100%">
        <el-table-column
            prop="date"
            label="线号">
        </el-table-column>
        <el-table-column
            prop="name"
            label="起端设备"
            width="180">
        </el-table-column>
        <el-table-column
            prop="address"
            label="起端子设备">
        </el-table-column>
        <el-table-column
            prop="address"
            label="起端插针号">
        </el-table-column>
        <el-table-column
            prop="address"
            label="起端物理地址">
        </el-table-column>
        <el-table-column
            prop="address"
            label="终端设备"
            width="180">
        </el-table-column>
        <el-table-column
            prop="address"
            label="终端子设备">
        </el-table-column>
        <el-table-column
            prop="address"
            label="终端插针号">
        </el-table-column>
        <el-table-column
            prop="address"
            label="终端物理地址">
        </el-table-column>
        <el-table-column
            prop="address"
            label="电阻值">
        </el-table-column>
        <el-table-column
            prop="address"
            label="测试结果">
        </el-table-column>
        <el-table-column
            prop="address"
            label="测试人">
        </el-table-column>
        <el-table-column
            prop="address"
            label="判据规则">
        </el-table-column>
        <el-table-column
            prop="address"
            label="测试时间">
        </el-table-column>
        <el-table-column
            prop="address"
            label="备注">
        </el-table-column>
      </el-table>
    </div>
    <el-dialog title="登录" :visible.sync="loginDialogFormVisible" width="500px">
      <el-form :model="loginForm">
        <el-form-item label="登录名" :label-width="formLabelWidth">
          <el-input v-model="loginForm.personName" autocomplete="off" placeholder="请输入登录名"></el-input>
        </el-form-item>
        <el-form-item label="登录密码" :label-width="formLabelWidth">
          <el-input v-model="loginForm.password" autocomplete="off" show-password placeholder="请输入登录密码"></el-input>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="loginDialogFormVisible = false">登  录</el-button>
      </div>
    </el-dialog>
    <taskList ref="taskListRef"></taskList>
  </div>
</template>

<script>
import { ipcRenderer } from 'electron'
import taskList from '@/components/taskList'
export default {
  components: {taskList},
  data() {
    return {
      qiduanVal: "",
      zhongduanVal:"",
      tableData:[],
      loginDialogFormVisible:false,
      formLabelWidth: '80px',
      loginForm:{
        personName:"",
        password:""
      },
      mac:''
    }
  },
  mounted(){
    // this.getMacAddress()
    this.loginDialogFormVisible = true
  },
  methods: {
    openTaskPopup(){
      this.$refs.taskListRef.dialogTableVisible=true
    },
    getMacAddress() {
      if(this.isElectron()){
        console.log("electron执行代码")
        const networkInterfaces = require('os').networkInterfaces();
        for (const name in networkInterfaces) {
          const addresses = networkInterfaces[name];
          for (const address of addresses) {
            if (address.family === 'IPv4' && !address.internal) {
              this.mac = address.mac
              break
            }
          }
        }
        console.log('MAC 地址:', this.mac)
      }
    },
    isElectron() {
      return !!(
          window &&
          window.process &&
          window.process.versions &&
          window.process.versions.electron
      );
    }
  }
}
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>

</style>
